package com.hanma.service.impl;

import java.util.List;

import com.hanma.bean.User;
import com.hanma.dao.UserDao;
import com.hanma.dao.impl.UserDaoImpl;
import com.hanma.service.UserService;

public class UserServiceImpl implements UserService{

	@Override
	public boolean insert(User user) {
		UserDao dao = new UserDaoImpl();
		int num = dao.insert(user);
		if(num>0) {
			return true;
		}
		return false;
	}

	@Override
	public boolean update(User user,Integer id) {
		UserDao dao = new UserDaoImpl();
		int num = dao.update(user,id);
		if(num>0) {
			return true;
		}
		return false;
	}

	@Override
	public boolean updateHead(Integer id, String head) {
		UserDao dao = new UserDaoImpl();
		int num = dao.updateHead(id,head);
		if(num>0) {
			return true;
		}
		return false;
	}

	@Override
	public boolean delete(Integer id) {
		UserDao dao = new UserDaoImpl();
		int num = dao.delete(id);
		if(num>0) {
			return true;
		}
		return false;
	}

	@Override
	public User find(String name,String password) {
		UserDao dao = new UserDaoImpl();
		return dao.find(name,password);
	}

	@Override
	public List<User> findAll() {
		UserDao dao = new UserDaoImpl();
		return dao.findAll();
	}

	@Override
	public List<User> findAll(Integer start, Integer size) {
		UserDao dao = new UserDaoImpl();
		return dao.findAll(start, size);
	}

	@Override
	public boolean findByName(String username) {
		UserDao dao = new UserDaoImpl();
		return dao.findByName(username);
	}

	@Override
	public User findById(Integer id) {
		UserDao dao = new UserDaoImpl();
		return dao.findById(id);
	}

}
